Repository navigation
Read PhysioNet records whose names include folders - #666
Conversation
rdheader, rdrecord and rdann with pn_dir dropped any folders at the start of
the record name, so rdrecord("files/p1000/.../40689238",
pn_dir="mimic-iv-ecg/1.0") looked for 40689238.hea at the top of the database.
Move those folders to the end of pn_dir instead, in one helper that also
adds the latest version, which was repeated in each function.
Segments of multi-segment records on PhysioNet are now read by name from
pn_dir, without the local directory that used to be joined to them and
then dropped.
Fixes #467.
tompollard
left a comment
There was a problem hiding this comment.
The folder-path handling looks sound. I ran the 29 focused offline tests and separately checked a cached variable-layout multi-segment record in a nested folder against the same local record; the signals matched. All 18 PR checks pass. I found no code issue.
One documentation fix: the public rdheader, rdrecord, and rdsamp docstrings still say that when pn_dir is set, record_name should contain only the base record name (src/wfdb/io/record.py:1883, :2108, and :2507). That contradicts the folder paths this PR now supports and could steer users away from the fix. Could those descriptions say that folders may be included in either record_name or pn_dir, as the new docs/io.rst example shows?
|
Thanks, agreed. In e7c1441, the The same old sentence was in 10 docstrings, so I changed all of them:
|
## Summary Bump the version from 5.1.0 to 5.2.0, and collect the 19 entries in `changelog.d/` into `docs/changes.rst` with `towncrier build --date "Nov 2026"`, with a short summary at the top of the new section. This is a minor release. The one change that existing code may notice is that `rdann` and `Annotation.apply_range` now stop before `sampto`, as `rdrecord` and `rdsamp` do, so an annotation exactly at `sampto` is no longer included (#667). The summary calls it out, with how to get the old result. The release also includes: - **Fixes for PhysioNet:** `get_dbs`, which PhysioNet's API change had broken (#665), record names with folders in `pn_dir` (#666), and `physionet://` and other URIs in `read_edf`, `rdedfann` and `read_wav` (#674). - **Robustness:** - headers whose base time or date is in another form (#668); - multi-segment writes that leave no partial record after an error (#673); - a warning before `wrsamp` replaces another record's signal files (#675). - **New:** a beat-by-beat comparison of annotation files, as WFDB `bxb` does, as a development feature (#679), and axis labels in `plot_wfdb` (#670). - **Smaller fixes:** - integer overflow and precision in `find_peaks` and `normalize_bound`; - constant signals in `normalize_bound`; - multi-character custom annotation symbols; - format 61 signals read with `smooth_frames=False`; - skew written twice when rewriting records; - docstring examples, and more. This will be the first release published by `.github/workflows/publish.yml`, from the GitHub release, with provenance. ## Checks - `pytest -m "not network"`: 679 passed (4 skipped, the `bxb` comparison that needs WFDB installed), also with `--python 3.11 --resolution lowest-direct`. `pytest -m network`: 20 passed. - Ruff and the Sphinx HTML build with warnings as errors pass. - The wheel and source distribution build and pass `twine check`. They have `Version: 5.2.0` and include `wfdb/processing/beat_comparison.py`. - PyPI has no 5.2.0 release yet. <sub>@tompollard 🟥 red 🦥 sloth · aspen</sub>
Fixes #467.
rdheader,rdrecord,rdsampandrdannwithpn_dirdropped any folders at the start of the record name. Sordrecord("files/p1000/p10000032/s40689238/40689238", pn_dir="mimic-iv-ecg/1.0")looked for40689238.heaat the top of the database, and failed with "file not found". The folders now move to the end ofpn_dir, so the folders can be given in either argument._resolve_pn_dir, does this and also adds the latest version whenpn_dirhas none. That code was repeated in each of the three functions.pn_dir. Before, the local working directory was joined to the segment name and then dropped along with any other folders. A network test (test_multi_variable_d[physionet]) caught this.docs/io.rstdescribes folders in either argument.Testing
pn_dirwith a version, without one, and with some of the folders inpn_dir. They fail onmain. A network test reads the MIMIC-IV-ECG record from the issue.pytest: all offline and network tests pass, also with--resolution lowest-direct. Ruff and the docs build pass.@tompollard 🟥 red 🦥 sloth · aspen